TARGET = pic_decode
SRCS = ijg_jpeg_demo.c bmp_encoder.c
CROSS_COMPILER = arm-linux-
CC = $(CROSS_COMPILER)gcc
RM = rm -vf

ROOT = /usr/local/arm_linux_4.2
LIBXML = $(ROOT)/libxml2_arm/lib
INCXML :=$(ROOT)/libxml2_arm/include/libxml2

LIBJPEG =./libjpeg
INCJPEG =./libjpeg

LIBPNG =
INCPNG =

CUR_DIR = $(shell pwd)
HEAD_DIR = $(CUR_DIR)/head

CFLAGS = -I$(INCJPEG)
LDFLAGS = -L$(LIBJPEG)

LIBS = -ljpeg

$(TARGET): $(SRCS:.c=.o)
	$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBS)
	cp $@ ../0app -vf

#模式规则: %号匹配所有的.o和.c文件(是一个循环取出的过程)
%.o: %.c 
	$(CC) $(CFLAGS) $(LDFLAGS) -c $< -o $@

#.dep文件存在的目的是：解决依赖于因头文件的更新而不会重新生成文件的问题	

%.dep: %.c
	$(CC) $(CFLAGS) $(LDFLAGS) -c -MM $< > $@.$$$$; \
	sed 's/$*.o: /$*.o $*.dep: /' $@.$$$$ > $@; \
	$(RM) $@.$$$$

sinclude $(SRCS:.c=.dep)

clean:
	$(RM) $(TARGET) $(SRCS:.c=.o) $(SRCS:.c=.dep) *~

.PHONY: clean
	
